module type GM = sig
  include Graph.Sig.I with type V.label=string*int
  module Mark : sig
    val get : V.t -> int
    val set : V.t -> int -> unit
  end
end

module type VM = sig
   type t
   val name : t -> string
   val color : t -> int
end

module Logger(G : GM)(VT : VM) = struct
open Graph

let print_graph g = 
    let print_vertex v = 
        let (n,m) = G.V.label v in 
        print_string (String.concat "" ["name = ";n; " ; label = " ]);
        print_int m;
        print_string (String.concat "" [" ; mark = "]);
        print_int(G.Mark.get v);
        print_string (String.concat "" [" ; degree = "]);
        print_int(G.out_degree g v);         
        print_string "\n";
    in     
    G.iter_vertex print_vertex g

let print_vertex_group v_gr = 
    let print_group gr = 
        print_string (String.concat "" ["group_color = "]);
        print_int (VT.color (List.hd gr));
        print_string "\n";
        print_string (String.concat "" ["group_size = "]);
        print_int (List.length gr);
        print_string "\n";
        List.iter (fun v -> print_string(String.concat "" ["     name = ";(VT.name v); " ; \n"])) gr;        
        in
    List.iter (fun v -> print_group v;print_string "\n") v_gr ;
    print_string "===========================================\n"

let print_stat eff_iter all_iter =
    Printf.printf "Execution time= %f ;\nEfficient iterate count= %i ;\nTotal iterate count= %i ;\n" (Sys.time()) eff_iter all_iter;
    if Array.length Sys.argv == 4
    then
      let oc = open_out Sys.argv.(3) in   
      Printf.fprintf oc "Input file name= %s ;\nResult file name= %s ;\nExecution time= %f ;\nEfficient iterate count= %i ;\nTotal iterate count= %i ;\n" 
                  Sys.argv.(1) Sys.argv.(2) (Sys.time()) eff_iter all_iter; 
      close_out oc

end